<?php
$o_message = Controller_Helper_Message::get_instance();
$a_error = $o_message->get_error();
$a_success = $o_message->get_success();
$a_warning = $o_message->get_warning();
$o_message->reset();

if (!empty($a_error)) {
    foreach ($a_error as $s_error) {
        ?>
        <div class="alert alert-danger ">
            <button data-dismiss="alert" class="close" type="button">
                <i class="icon-remove"></i>
            </button>
            <span>
                <?= $s_error ?>
            </span>
            <br>
        </div>

        <?php
    }
}
?>

<?php
if (!empty($a_success)) {
    foreach ($a_success as $s_success) {
        ?>
        <div class="alert alert-block alert-success success-alert">
            <button data-dismiss="alert" class="close" type="button">
                <i class="icon-remove"></i>
            </button>
            <span>
                <?= $s_success ?>
            </span>
        </div>
        <script>

            setTimeout(function() {
                jQuery(".success-alert").hide();
            }, 5000);

        </script>
        <?php
    }
}
?>

<?php
if (!empty($a_warning)) {
    foreach ($a_warning as $s_warning) {
        ?>
        <div class="alert alert-warning">
            <button data-dismiss="alert" class="close" type="button">
                <i class="icon-remove"></i>
            </button>
            <span>
                <?= $s_warning ?>
            </span>
            <br>
        </div>

        <?php
    }
}
?>

<div class="alert alert-danger error-alert" style="display: none;" id="error-alert">
    <button data-dismiss="alert" class="close" type="button">
        <i class="icon-remove"></i>
    </button>
    <span>
        
    </span>
    <br>
</div>
<div class="alert alert-block alert-success success-alert" style="display: none;" id="success-alert">
    <button data-dismiss="alert" class="close" type="button">
        <i class="icon-remove"></i>
    </button>
    <span>
        
    </span>
</div>
<script>
    function show_msg_error(msg) {
        jQuery("#error-alert").show();
        jQuery("#error-alert span").html(msg);
        //window.location = '<?= Controller_Helper_Url::full_url() ?>' + "#error-alert";
        jQuery('#btn-scroll-up').click();
        setTimeout(function() {
            jQuery("#error-alert").hide();
            jQuery("#error-alert").parent().parent().removeClass('has-error');
        }, 5000);
    }

    function show_msg_success(msg) {
        jQuery("#success-alert").show();
        jQuery("#success-alert span").html(msg);
        //window.location = '<?= Controller_Helper_Url::full_url() ?>' + "#success-alert";
        jQuery('#btn-scroll-up').click();
        setTimeout(function() {
            jQuery("#success-alert").hide();
            jQuery("#error-alert").parent().parent().removeClass('has-error');
        }, 5000);
    }
</script>